package me.wangxuan.pat;
import javax.swing.*;
import java.awt.*;
public class ApiInterfaceUI extends JFrame {
	public ApiInterfaceUI() {
        setTitle("API Interface");
        setSize(600, 400);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLayout(new BorderLayout());

        // Top panel with project name and address
        JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
        topPanel.add(new JLabel("项目名:"));
        JTextField projectNameField = new JTextField("000000", 10);
        topPanel.add(projectNameField);
        topPanel.add(new JLabel("地址:"));
        JTextField addressField = new JTextField("http://", 20);
        topPanel.add(addressField);
        add(topPanel, BorderLayout.NORTH);

        // Main panel with tabs
        JPanel mainPanel = new JPanel();
        add(mainPanel, BorderLayout.CENTER);

        // Tabbed pane for public parameters, collection, and history
        JTabbedPane tabbedPane = new JTabbedPane();
        mainPanel.add(tabbedPane);

        // Public parameters tab
        JPanel publicParamsPanel = new JPanel(new GridLayout(1, 2));
        publicParamsPanel.add(new JLabel("公共参数"));
        JTextField publicParamsField = new JTextField(20);
        publicParamsPanel.add(publicParamsField);
        tabbedPane.addTab("公共参数", publicParamsPanel);

        // Collection tab
        JPanel collectionPanel = new JPanel(new GridLayout(1, 1));
        collectionPanel.add(new JLabel("接口集合"));
        JTextArea collectionArea = new JTextArea(5, 20);
        collectionPanel.add(new JScrollPane(collectionArea));
        tabbedPane.addTab("接口集合", collectionPanel);

        // History tab
        JPanel historyPanel = new JPanel(new GridLayout(1, 1));
        historyPanel.add(new JLabel("历史"));
        JTextArea historyArea = new JTextArea(5, 20);
        historyPanel.add(new JScrollPane(historyArea));
        tabbedPane.addTab("历史", historyPanel);

        // Parameters and result panel
        JPanel paramsResultPanel = new JPanel(new BorderLayout());
        mainPanel.add(paramsResultPanel, BorderLayout.CENTER);

        // Parameters panel
        JPanel paramsPanel = new JPanel(new GridLayout(3, 1));
        paramsPanel.add(new JLabel("参数"));
        JTextField paramField1 = new JTextField(20);
        JTextField paramField2 = new JTextField(20);
        paramsPanel.add(paramField1);
        paramsPanel.add(paramField2);
        paramsResultPanel.add(paramsPanel, BorderLayout.WEST);

        // Result panel
        JPanel resultPanel = new JPanel(new GridLayout(1, 1));
        resultPanel.add(new JLabel("结果"));
        JTextArea resultArea = new JTextArea(5, 20);
        resultPanel.add(new JScrollPane(resultArea));
        paramsResultPanel.add(resultPanel, BorderLayout.CENTER);

        setVisible(true);
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                new ApiInterfaceUI();
            }
        });
    }
}
